package com.wutuo.aggragation.wtservice.controller;

import cn.apestar.core.base.BaseMessage;
import com.wutuo.wtservice.api.WtTypeAPIService;
import com.wutuo.wtservice.api.request.WtTypeRequest;
import com.wutuo.wtservice.api.response.WtTypeResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * 管护类型表 <br>
 * 详细说明.
 * <p>
 *
 * @author lvh
 * @version 1.0
 */
@RestController @RequestMapping(value = "/wttype", produces = "application/json")
public class WtTypeController {

    private Logger logger = LoggerFactory.getLogger(WtTypeController.class);

    @Autowired private WtTypeAPIService wtTypeService;

    /**
     * 新增管护关系表
     *
     * @param request
     */
    @RequestMapping(value = "/addorUpdate", method = RequestMethod.POST) public Object create(
        @RequestBody @Valid WtTypeRequest request) {

        wtTypeService.addorUpdate(request);
        return new BaseMessage();
    }

    /**
     * 删除管护类型表
     *
     * @param userId
     */
    @RequestMapping(value = "/del/{id}", method = RequestMethod.GET) public Object del(
        @PathVariable("id") Long id) {

        wtTypeService.del(id);
        return new BaseMessage();
    }

    /**
     * 查询管护类型表
     *
     * @param name
     * @return
     */
    @RequestMapping(value = "/list", method = RequestMethod.POST) public List<WtTypeResponse> list(
        @RequestBody WtTypeRequest request) {

        List list = wtTypeService.list(request);
        return list;
    }
}